<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<c:set var="contextPath" value="${pageContext.request.contextPath}/" />

<link rel="stylesheet" href="http://cdn.bootcss.com/light7/0.4.3/css/light7.min.css">
<link rel="stylesheet" href="${contextPath}resources/css/common.css">

<script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/jquery.form/4.2.1/jquery.form.js"></script>
<script src="http://cdn.bootcss.com/light7/0.4.3/js/light7.min.js"></script>
<script src="http://cdn.bootcss.com/light7/0.4.3/js/light7-swipeout.min.js"></script>
<script src="http://cdn.bootcss.com/light7/0.4.3/js/i18n/cn.min.js"></script>
<script src="${contextPath}resources/js/jweixin-1.0.0.js"></script>
<script src="${contextPath}resources/js/jquery.custom.js"></script>
<script>
	var isWxReady = false;
	
	/**
	 * 初始化微信JS-SDK
	 * @param appId 公众号的唯一标识
	 * @param timestamp 生成签名的时间戳
	 * @param nonceStr 生成签名的随机串
	 * @param signature 签名
	 * @author mengbin
	 * @since 2016/5/14
	 */
	function initWx(appId, timestamp, nonceStr, signature) {
		wx.config({
		    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		    appId: appId,
		    timestamp: timestamp,
		    nonceStr: nonceStr,
		    signature: signature,
		    jsApiList: ['hideOptionMenu', 'hideAllNonBaseMenuItem'] // 需要使用的JS接口列表
		});
	}

	$.post({
		url: '${contextPath}ticket/jsapiTicket',
		async: false,
		dataType: 'json',
		data: {
			url: encodeURIComponent(location.href.split('#')[0])
		},
		success: function(json) {
			if (json != null) {
				initWx(json.appId, json.timestamp, json.noncestr, json.signature);
			}
		},
		error: function() {
			alert('[${contextPath}ticket/jsapiTicket] ajax ERROR!');
		}
	});
	
	wx.ready(function() {
		wx.hideOptionMenu();
		wx.hideAllNonBaseMenuItem();
		isWxReady = true;
	});
</script>
